Mail subsystem XSD. (Shows empty page in some browsers - view the source.)
Excerpt:
mail-session may contain: ( smtp-server | imap-server | pop3-server )*
@jndi-name
@debug Enables debuging of mail session
@from Sets mail.from attribute
*-server may contain: login
@ssl Enables use of ssl for this server configuration. Typically, used with an outbound socket with port 465.
@tsl Enables use of tls for this server configuration.
@outbound-socket-binding-ref Reference to the outbound-socket-binding element in the socket-binding-group that should
be used for configuring the client socket used to communicate with the mail server.
Example mail subsystem configuration:
<subsystem xmlns="urn:jboss:domain:mail:1.0">
<mail-session jndi-name="java:jboss/mail/Default">
<smtp-server ssl="true" outbound-socket-binding-ref="smtp-example">
<login name="foo@example.com" password="12345"/>
</smtp-server>
</mail-session>
<mail-session jndi-name="java:jboss/mail/RedHat">
<smtp-server ssl="true" outbound-socket-binding-ref="smtp-seznam">
<login name="bar@seznam.cz" password="12345"/>
</smtp-server>
</mail-session>
</subsystem>
...
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
...
<outbound-socket-binding name="smtp-example">
<remote-destination host="smtp.example.com" port="465"/>
</outbound-socket-binding>
<outbound-socket-binding name="smtp-seznam" source-port="0" fixed-source-port="false">
<remote-destination host="smtp.seznam.cz" port="465"/>
</outbound-socket-binding>
</socket-binding-group>
public class MailSender {
@Resource(mappedName="java:jboss/mail/Default")
private Session mailSessionSeznam;
private void sendMail(Session mailSessionSeznam, String mailFrom, String sMailTo, String sSubject, String sMailText) throws MessagingException {
MimeMessage message = new MimeMessage( mailSessionSeznam );
message.setFrom( new InternetAddress( mailFrom ) );
message.setReplyTo( new Address\[\]{new InternetAddress( this.mailReplyTo )} );
message.addRecipient( Message.RecipientType.TO, new InternetAddress( sMailTo ) );
message.setHeader( "Content-Type", this.mailContentType + "; charset=\"" + this.mailEncoding + "\"");
message.setSubject( sSubject );
message.setText( sMailText );
Transport.send( message ); }// sendMail()
}
}